/* 
 * File:   Box2DNode.h
 * Author: aljosa
 *
 * Created on May 31, 2010, 10:25 PM
 */

#ifndef _BOX2DNODE_H
#define	_BOX2DNODE_H

#include <Box2D/Box2D.h>
#include "SceneNode.h"

#define BOX2D_SCALE 1.0f

#define WORLD_TO_SCREEN(a) (a*BOX2D_SCALE)
#define SCREEN_TO_WORLD(a) (a/BOX2D_SCALE)

namespace xEngine
{
    namespace PlatformIndependent
    {
        // Shape enumerator
        enum SHAPE {
            CIRCLE, RECTANGLE, POLYGON
        };

        class Box2DNode : public SceneNode {
        public:
            Box2DNode(b2World *world);
            virtual ~Box2DNode();

            // Entity creation - manipulation

            // Init functions
            virtual void init();
            virtual void init( const b2Vec2 &size, const b2Vec2 &pos );
            virtual void init( float radius, const b2Vec2 &pos );

            // Shape creators
            virtual void createShape();
            virtual void createShape( const b2Vec2 &size, const b2Vec2 &pos );
            virtual void createShape( float radius, const b2Vec2 &pos );

            // Appear func
            virtual void appear(bool dynamic);

            // Node overloaded stuff
            virtual void draw(double deltaTime); // Default wire draw
            virtual void release();

            // Box2D internal
            b2BodyDef *bodyDef;
            b2Body *body;
            b2ShapeDef *shapeDef;

            void *shapeData;

        protected:
            b2World *world;


        };
    }
}



#endif	/* _BOX2DNODE_H */

